package Managment;

import java.util.ArrayList;
import java.util.List;

import NegocioVO.PlatoVO;
import bean.PlatoBean;
import dao.PlatoDao;


public class ManagmentPlato {
	
	private static ManagmentPlato instancia;
	
	public static ManagmentPlato getInstancia(){
		if(instancia == null)
			instancia = new ManagmentPlato();
		return instancia;
	}

	
	public List<PlatoVO> listarPlatosDisponibles(int Local)
	{
		List<PlatoBean> platoB = new ArrayList<PlatoBean>();
		List<PlatoVO> platoV = new ArrayList<PlatoVO>();
		PlatoDao platoD = new PlatoDao();
		platoB.addAll(platoD.listaPlatoDelLocal(Local));
		platoV.addAll(this.ListHibernateaVo(platoB));
		return platoV;
		
	}

	private List<PlatoVO> ListHibernateaVo(List<PlatoBean> platoB) 
	{
		List<PlatoVO> platosVO = new ArrayList<PlatoVO>();
		for(int i = 0; platoB.size() - 1 >= i; i++)
		{
			platosVO.add(this.HibernateAVo(platoB.get(i)));
		}
		return platosVO;
	}

	private PlatoVO HibernateAVo(PlatoBean platoBean) {
		PlatoVO platovo = new PlatoVO();
		platovo.setComisionExtra(platoBean.getComisionExtra());
		platovo.setDescripcion(platoBean.getDescripcion());
		platovo.setIdPlato(platoBean.getIdPlato());
		platovo.setIsActivo(platoBean.getIsActivo());
		platovo.setPrecio(platoBean.getPrecio());
		platovo.setReceta(ManagmentReceta.getInstancia().HibernateAVo(platoBean.getReceta()));
		platovo.setTipo(platoBean.getTipo());
		return platovo;
	}


	public PlatoBean VoAHibernate(PlatoVO plato) {
		// TODO Auto-generated method stub
		return null;
	}
}
